import Vue from 'vue'
import App from './App'
import store from '@/store/store.js'

// import pageHead from './components/page-head.vue'
// import pageFoot from './components/page-foot.vue'
// import uLink from '@/components/uLink.vue'
// import store from './store'
// 导入网络请求的包
import { $http } from '@escook/request-miniprogram'

// 给uni挂载网络请求
uni.$http = $http

// 设置网络请求的根路径 www.zhengzhicheng.cn https:/autumnfish.cn/wx
$http.baseUrl = 'https://www.uinav.com'

// 请求结束后的弹窗提示
uni.$showMsg = function (title='请求数据失败！', duration=1500) {
	uni.showToast({
		title,
		duration,
		icon: 'none'
	})
}


// 请求拦截器
$http.beforeRequest = function (options) {
	uni.showLoading({
		title: '数据加载中...'
	})

	
	if (options.url.indexOf('/my/') !== -1) {
		options.header = {
			Authorization: store.state['my-user'].token
		}
	}
}

// 响应拦截器
$http.afterRequest = function (options) {
	uni.hideLoading()
}

Vue.config.productionTip = false

// Vue.prototype.$store = store
// Vue.prototype.$backgroundAudioData = {
// 	playing: false,
// 	playTime: 0,
// 	formatedPlayTime: '00:00:00'
// }

// Vue.component('page-head', pageHead)
// Vue.component('page-foot', pageFoot)
// Vue.component('uLink', uLink)

App.mpType = 'app'

const app = new Vue({
	...App,
	store
})
app.$mount()
